"""
@Author  : 康帅
@Time    : 2021/3/10 9:31
@Function: __dict__及实例参数
"""


class Person:
    def __init__(self, name, age):
        """
        根据这个字典来构建一个对象
        :param name: ks
        :param age: 24
        """
        print(self.__dict__)  # {}
        self.name = name
        print(self.__dict__)  # {"name":"ks"}
        self.age = age
        print(self.__dict__)  # {"name":"ks", "age": 24}


class PersonV2:
    def __init__(self):
        """
        根据这个字典来构建一个对象
        """
        print(self.__dict__)  # {}
        self.name = "ks"
        print(self.__dict__)  # {"name":"ks"}
        self.age = 24
        print(self.__dict__)  # {"name":"ks", "age": 24}


if __name__ == '__main__':
    data = Person("ks", 24)
    data_v2 = PersonV2()
    print(data.__dict__)  # {"name":"ks", "age": 24}
    print(data_v2.__dict__)  # {"name":"ks", "age": 24}
